/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.UserEntry;
import vn.com.fis.portal.model.UserEntryModel;
import vn.com.fis.portal.model.UserEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the UserEntry service. Represents a row in the &quot;tbl_user&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.UserEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UserEntryImpl}.
 * </p>
 *
 * @author loind
 * @see UserEntryImpl
 * @see vn.com.fis.portal.model.UserEntry
 * @see vn.com.fis.portal.model.UserEntryModel
 * @generated
 */
@JSON(strict = true)
public class UserEntryModelImpl extends BaseModelImpl<UserEntry>
	implements UserEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a user entry model instance should use the {@link vn.com.fis.portal.model.UserEntry} interface instead.
	 */
	public static final String TABLE_NAME = "tbl_user";
	public static final Object[][] TABLE_COLUMNS = {
			{ "userId", Types.BIGINT },
			{ "userName", Types.VARCHAR },
			{ "mobilePhone", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "serviceId", Types.BIGINT },
			{ "serviceStatus", Types.INTEGER },
			{ "serviceStartDate", Types.TIMESTAMP },
			{ "serviceStopDate", Types.TIMESTAMP },
			{ "servicePackageId", Types.BIGINT },
			{ "servicePackageStatus", Types.INTEGER },
			{ "servicePackageStartDate", Types.TIMESTAMP },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "description", Types.VARCHAR },
			{ "status", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table tbl_user (userId LONG not null primary key,userName VARCHAR(75) null,mobilePhone VARCHAR(75) null,groupId LONG,companyId LONG,serviceId LONG,serviceStatus INTEGER,serviceStartDate DATE null,serviceStopDate DATE null,servicePackageId LONG,servicePackageStatus INTEGER,servicePackageStartDate DATE null,createDate DATE null,modifiedDate DATE null,description VARCHAR(75) null,status INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table tbl_user";
	public static final String ORDER_BY_JPQL = " ORDER BY userEntry.userName ASC, userEntry.mobilePhone ASC";
	public static final String ORDER_BY_SQL = " ORDER BY tbl_user.userName ASC, tbl_user.mobilePhone ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.UserEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.UserEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.UserEntry"),
			true);
	public static long MOBILEPHONE_COLUMN_BITMASK = 1L;
	public static long SERVICEID_COLUMN_BITMASK = 2L;
	public static long USERNAME_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static UserEntry toModel(UserEntrySoap soapModel) {
		UserEntry model = new UserEntryImpl();

		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setMobilePhone(soapModel.getMobilePhone());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setServiceId(soapModel.getServiceId());
		model.setServiceStatus(soapModel.getServiceStatus());
		model.setServiceStartDate(soapModel.getServiceStartDate());
		model.setServiceStopDate(soapModel.getServiceStopDate());
		model.setServicePackageId(soapModel.getServicePackageId());
		model.setServicePackageStatus(soapModel.getServicePackageStatus());
		model.setServicePackageStartDate(soapModel.getServicePackageStartDate());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setDescription(soapModel.getDescription());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<UserEntry> toModels(UserEntrySoap[] soapModels) {
		List<UserEntry> models = new ArrayList<UserEntry>(soapModels.length);

		for (UserEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final String MAPPING_TABLE_TBL_VIDEO_USER_NAME = "tbl_video_user";
	public static final Object[][] MAPPING_TABLE_TBL_VIDEO_USER_COLUMNS = {
			{ "videoId", Types.BIGINT },
			{ "userId", Types.BIGINT }
		};
	public static final String MAPPING_TABLE_TBL_VIDEO_USER_SQL_CREATE = "create table tbl_video_user (videoId LONG not null,userId LONG not null,primary key (videoId, userId))";
	public static final boolean FINDER_CACHE_ENABLED_TBL_VIDEO_USER = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.tbl_video_user"), true);
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.UserEntry"));

	public UserEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _userId;
	}

	public void setPrimaryKey(long primaryKey) {
		setUserId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_userId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return UserEntry.class;
	}

	public String getModelClassName() {
		return UserEntry.class.getName();
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	@JSON
	public String getUserName() {
		if (_userName == null) {
			return StringPool.BLANK;
		}
		else {
			return _userName;
		}
	}

	public void setUserName(String userName) {
		_columnBitmask = -1L;

		if (_originalUserName == null) {
			_originalUserName = _userName;
		}

		_userName = userName;
	}

	public String getOriginalUserName() {
		return GetterUtil.getString(_originalUserName);
	}

	@JSON
	public String getMobilePhone() {
		if (_mobilePhone == null) {
			return StringPool.BLANK;
		}
		else {
			return _mobilePhone;
		}
	}

	public void setMobilePhone(String mobilePhone) {
		_columnBitmask = -1L;

		if (_originalMobilePhone == null) {
			_originalMobilePhone = _mobilePhone;
		}

		_mobilePhone = mobilePhone;
	}

	public String getOriginalMobilePhone() {
		return GetterUtil.getString(_originalMobilePhone);
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_groupId = groupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public long getServiceId() {
		return _serviceId;
	}

	public void setServiceId(long serviceId) {
		_columnBitmask |= SERVICEID_COLUMN_BITMASK;

		if (!_setOriginalServiceId) {
			_setOriginalServiceId = true;

			_originalServiceId = _serviceId;
		}

		_serviceId = serviceId;
	}

	public long getOriginalServiceId() {
		return _originalServiceId;
	}

	@JSON
	public int getServiceStatus() {
		return _serviceStatus;
	}

	public void setServiceStatus(int serviceStatus) {
		_serviceStatus = serviceStatus;
	}

	@JSON
	public Date getServiceStartDate() {
		return _serviceStartDate;
	}

	public void setServiceStartDate(Date serviceStartDate) {
		_serviceStartDate = serviceStartDate;
	}

	@JSON
	public Date getServiceStopDate() {
		return _serviceStopDate;
	}

	public void setServiceStopDate(Date serviceStopDate) {
		_serviceStopDate = serviceStopDate;
	}

	@JSON
	public long getServicePackageId() {
		return _servicePackageId;
	}

	public void setServicePackageId(long servicePackageId) {
		_servicePackageId = servicePackageId;
	}

	@JSON
	public int getServicePackageStatus() {
		return _servicePackageStatus;
	}

	public void setServicePackageStatus(int servicePackageStatus) {
		_servicePackageStatus = servicePackageStatus;
	}

	@JSON
	public Date getServicePackageStartDate() {
		return _servicePackageStartDate;
	}

	public void setServicePackageStartDate(Date servicePackageStartDate) {
		_servicePackageStartDate = servicePackageStartDate;
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_status = status;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public UserEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (UserEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
					UserEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		UserEntryImpl userEntryImpl = new UserEntryImpl();

		userEntryImpl.setUserId(getUserId());
		userEntryImpl.setUserName(getUserName());
		userEntryImpl.setMobilePhone(getMobilePhone());
		userEntryImpl.setGroupId(getGroupId());
		userEntryImpl.setCompanyId(getCompanyId());
		userEntryImpl.setServiceId(getServiceId());
		userEntryImpl.setServiceStatus(getServiceStatus());
		userEntryImpl.setServiceStartDate(getServiceStartDate());
		userEntryImpl.setServiceStopDate(getServiceStopDate());
		userEntryImpl.setServicePackageId(getServicePackageId());
		userEntryImpl.setServicePackageStatus(getServicePackageStatus());
		userEntryImpl.setServicePackageStartDate(getServicePackageStartDate());
		userEntryImpl.setCreateDate(getCreateDate());
		userEntryImpl.setModifiedDate(getModifiedDate());
		userEntryImpl.setDescription(getDescription());
		userEntryImpl.setStatus(getStatus());

		userEntryImpl.resetOriginalValues();

		return userEntryImpl;
	}

	public int compareTo(UserEntry userEntry) {
		int value = 0;

		value = getUserName().compareTo(userEntry.getUserName());

		if (value != 0) {
			return value;
		}

		value = getMobilePhone().compareTo(userEntry.getMobilePhone());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		UserEntry userEntry = null;

		try {
			userEntry = (UserEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = userEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		UserEntryModelImpl userEntryModelImpl = this;

		userEntryModelImpl._originalUserName = userEntryModelImpl._userName;

		userEntryModelImpl._originalMobilePhone = userEntryModelImpl._mobilePhone;

		userEntryModelImpl._originalServiceId = userEntryModelImpl._serviceId;

		userEntryModelImpl._setOriginalServiceId = false;

		userEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<UserEntry> toCacheModel() {
		UserEntryCacheModel userEntryCacheModel = new UserEntryCacheModel();

		userEntryCacheModel.userId = getUserId();

		userEntryCacheModel.userName = getUserName();

		String userName = userEntryCacheModel.userName;

		if ((userName != null) && (userName.length() == 0)) {
			userEntryCacheModel.userName = null;
		}

		userEntryCacheModel.mobilePhone = getMobilePhone();

		String mobilePhone = userEntryCacheModel.mobilePhone;

		if ((mobilePhone != null) && (mobilePhone.length() == 0)) {
			userEntryCacheModel.mobilePhone = null;
		}

		userEntryCacheModel.groupId = getGroupId();

		userEntryCacheModel.companyId = getCompanyId();

		userEntryCacheModel.serviceId = getServiceId();

		userEntryCacheModel.serviceStatus = getServiceStatus();

		Date serviceStartDate = getServiceStartDate();

		if (serviceStartDate != null) {
			userEntryCacheModel.serviceStartDate = serviceStartDate.getTime();
		}
		else {
			userEntryCacheModel.serviceStartDate = Long.MIN_VALUE;
		}

		Date serviceStopDate = getServiceStopDate();

		if (serviceStopDate != null) {
			userEntryCacheModel.serviceStopDate = serviceStopDate.getTime();
		}
		else {
			userEntryCacheModel.serviceStopDate = Long.MIN_VALUE;
		}

		userEntryCacheModel.servicePackageId = getServicePackageId();

		userEntryCacheModel.servicePackageStatus = getServicePackageStatus();

		Date servicePackageStartDate = getServicePackageStartDate();

		if (servicePackageStartDate != null) {
			userEntryCacheModel.servicePackageStartDate = servicePackageStartDate.getTime();
		}
		else {
			userEntryCacheModel.servicePackageStartDate = Long.MIN_VALUE;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			userEntryCacheModel.createDate = createDate.getTime();
		}
		else {
			userEntryCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			userEntryCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			userEntryCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		userEntryCacheModel.description = getDescription();

		String description = userEntryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			userEntryCacheModel.description = null;
		}

		userEntryCacheModel.status = getStatus();

		return userEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(33);

		sb.append("{userId=");
		sb.append(getUserId());
		sb.append(", userName=");
		sb.append(getUserName());
		sb.append(", mobilePhone=");
		sb.append(getMobilePhone());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", serviceId=");
		sb.append(getServiceId());
		sb.append(", serviceStatus=");
		sb.append(getServiceStatus());
		sb.append(", serviceStartDate=");
		sb.append(getServiceStartDate());
		sb.append(", serviceStopDate=");
		sb.append(getServiceStopDate());
		sb.append(", servicePackageId=");
		sb.append(getServicePackageId());
		sb.append(", servicePackageStatus=");
		sb.append(getServicePackageStatus());
		sb.append(", servicePackageStartDate=");
		sb.append(getServicePackageStartDate());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(52);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.UserEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userName</column-name><column-value><![CDATA[");
		sb.append(getUserName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>mobilePhone</column-name><column-value><![CDATA[");
		sb.append(getMobilePhone());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>serviceId</column-name><column-value><![CDATA[");
		sb.append(getServiceId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>serviceStatus</column-name><column-value><![CDATA[");
		sb.append(getServiceStatus());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>serviceStartDate</column-name><column-value><![CDATA[");
		sb.append(getServiceStartDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>serviceStopDate</column-name><column-value><![CDATA[");
		sb.append(getServiceStopDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>servicePackageId</column-name><column-value><![CDATA[");
		sb.append(getServicePackageId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>servicePackageStatus</column-name><column-value><![CDATA[");
		sb.append(getServicePackageStatus());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>servicePackageStartDate</column-name><column-value><![CDATA[");
		sb.append(getServicePackageStartDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = UserEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			UserEntry.class
		};
	private long _userId;
	private String _userUuid;
	private String _userName;
	private String _originalUserName;
	private String _mobilePhone;
	private String _originalMobilePhone;
	private long _groupId;
	private long _companyId;
	private long _serviceId;
	private long _originalServiceId;
	private boolean _setOriginalServiceId;
	private int _serviceStatus;
	private Date _serviceStartDate;
	private Date _serviceStopDate;
	private long _servicePackageId;
	private int _servicePackageStatus;
	private Date _servicePackageStartDate;
	private Date _createDate;
	private Date _modifiedDate;
	private String _description;
	private int _status;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private UserEntry _escapedModelProxy;
}